import { ref } from 'vue';
import  axios  from 'axios';

function useHttpRequestDispersed(url:string){
    const loading = ref(true);
    const loaded = ref(false);
    const result = ref(null);
    const error = ref(null);
    
    axios.get(url).then((res:any) => {
        loading.value = false;
        loaded.value = true;
        result.value = res.data;
        error.value = null;
    }).catch((e:any)=>{
        loading.value = true;
        loaded.value = false;
        result.value = null;
        error.value = e;
    })

    return { loading,loaded,result,error };
    
}

export default useHttpRequestDispersed